package com.cn.zpark;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @PackageName: com.cn.zpark
 * @ClassName: MyServletDemo03
 * @Description:
 * @author: RZS
 * @date: 2022/4/6  11:29
 */
public class MyServletDemo03 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 响应数据到浏览器
        resp.setContentType("text/html;charset=utf-8");// 设置响应类型及编码
        // 创建响应写内容对象
        PrintWriter w = resp.getWriter();
        w.println("<h1>这个自己写的servlet响应的内容</h1>");


        // 关闭写资源
        w.close();
    }
}
